package com.neu.cloudFactory.DAO;

import com.neu.cloudFactory.PO.Bid;
import com.neu.cloudFactory.PO.Order;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface OrderDAO extends JpaRepository<Order,Integer> {
    //带有CRUD接口
    List<Order> findByOrderStateForCustomer(String orderStateForCustomer);
    List<Order> findByUserAccount(String account);

    //改变经销商的订单状态
    @Modifying
    @Query(value = "update orders set o_customer_state = :curState where o_id = :curId", nativeQuery = true)
    void modifyCustomerState(@Param("curState") String curState, @Param("curId") int curId);

    //改变云工厂的订单状态
    @Modifying
    @Query(value = "update orders set o_factory_state = :curState where o_id = :curId", nativeQuery = true)
    void modifyFactoryState(@Param("curState") String curState, @Param("curId") int curId);

    //新增中标工厂id
    @Modifying
    @Query(value = "update orders set f_id = :newId where o_id = :curId", nativeQuery = true)
    void modifyFactoryId(@Param("newId") int newId, @Param("curId") int curId);

    Order findOrderByCode(String code);


}
